package com.xjtu.chapter03;

/**
 * @author yjq
 * @version 1.0
 * @date 2021/8/11 21:16
 */
public class Ex3_StringMethodTest {
    //测试String类的常用方法，实现字符串替换、单个字符检索、查找子串、比较、去空格等功能
    public static void main(String[] args) {
        String str = "Welcome to Java";
        System.out.println(str+"的字符长度为: "+str.length());
        System.out.println(str+"中第五个字符是："+str.charAt(5));
        System.out.println(str+"与hello world相同："+ str.equalsIgnoreCase("hello world"));
        System.out.println(str+"用'L'代替'l'以后为："+str.replace("l","L"));
        System.out.println(str+"用'J'结尾："+str.endsWith("J"));
        System.out.println(str+"从第五个字符开始的字串为："+str.substring(5));
        System.out.println("  Thanks  "+"去掉开头和结尾的空格为："+"  Thanks  ".trim());
    }
}
